
#include <iostream>
#include <list>

using namespace std;

void print(string const& str, list<int> l){
	cout << str << endl;
/*
	typedef list<int>::iterator IT;
	for(IT it = l.begin(); it != l.end(); ++it)
		cout << *it << ' ';
*/
	for(auto const& n : l)
		cout << n << ' ';
	cout << endl << "--------------------------------" << endl;
}

int main(){
	list<int> ls;
	for(int i = 0; i < 5; ++i)
		ls.push_front(i);
	for(int i = 0; i < 5; ++i)
		ls.push_back(i);
	print("Insert ", ls);

	ls.insert(++ls.begin(), 14);
	print("Insert after iterator", ls);

	// unique
	ls.unique();
	print("Unique", ls);

	ls.remove(3);
	print("After remove", ls);

	// sort
	ls.sort();	// "<"
	ls.sort(greater<int>());	// using compear
	print("After sort", ls);

	list<int> lst;
	lst.push_back(1000);
	lst.push_back(2000);
	lst.push_back(3000);
	lst.push_back(4000);
	lst.push_back(5000);
	lst.push_back(6000);

//	ls.splice(ls.begin(), lst);
//	ls.splice(++ls.begin(), lst, --lst.end());
	ls.splice(--ls.end(), lst, ++lst.begin(), --lst.end());
	print("Splice", ls);
	print("lst", lst);

	return 0;
}
